var niceScrobj = null, dealflag = "home";
var winWidth = 0, winHeight = 0, minwidth = 640;
//显示菜单
function showMenu() {
	init();
	if(dealflag=="menu"){
		$("#content").css("margin-left", winWidth * 0.9 + "px");
	}else{
		dealflag = "menu";
		$("#menu").slideToggle();
		$("#content").animate({"margin-left": winWidth * 0.9 +"px"},function (){
			$("#home1").getNiceScroll().resize();
		});
	}
}
//显示消息
function showMsg() {
	init();
	if(dealflag=="msg"){
		$("#content").css("margin-left", - winWidth * 0.9 + "px");
	}else{
		dealflag = "msg";
		$("#message").slideToggle();
		$("#content").animate({"margin-left": - winWidth * 0.9 + "px"},function (){
			$("#home1").getNiceScroll().resize();
		});
	}
}
//显示主页内容
function returnHome() {
	if(dealflag == "menu")
		$("#menu").slideToggle();
	if(dealflag == "msg")
		$("#message").slideToggle();
	$("#content").animate({"margin-left": "0px"},function (){
			$("#home1").getNiceScroll().resize();
	});
	dealflag = "home";
}
//获取页面宽高
function init() {
	winWidth = $(window).width();
	winHeight = $(window).height();
	if (winWidth <= minwidth) {
		winWidth = minwidth;
	}
}
//重设页面宽度，菜单与消息，以页面宽度的90%显示，展示时将有10%页面显示主页内容
function resize() {
	init();
	var titleheight=$(".header").css("height").replace("px","");
	$("#menu").css("width", winWidth * 0.9 + "px");
	$("#content").css("width", winWidth * 0.9 + "px");
	$("#content").css("width", winWidth + "px");
	$("#bodyobj").css("width", winWidth + "px");
	$("#home1").css("height", (winHeight - parseInt(titleheight)) + "px");
	$("#home1").getNiceScroll().resize();
	if (dealflag == "menu")
		showMenu();
	if (dealflag == "msg")
		showMsg();
}
//页面加载完成执行
$(function () {
	init();
	window.scrollTo(0, 1);
	window.setTimeout("resize()", 100);
	niceScrobj = $("#home1").niceScroll();
	$("html").niceScroll();
	$(document).ready(function(e) {
	setTimeout(function(){
		var titleheight=$(".header").css("height").replace("px","");
		$("#home1").css("height", (winHeight - parseInt(titleheight)) + "px");
	},500);
});
});
